/**
 * date: 2018年2月23日
 *
 * js循环遍历节点,并将纯文本包装(wrap)
 */
var LoopInlineNodes = /** @class */ (function () {
    function LoopInlineNodes() {
        this.regexp = new RegExp("(<.+?>).+(<\/.+?>)");
        this.htmlStr = '';
    }
    // public constructor(){
    // }
    LoopInlineNodes.prototype.getHtmlStr = function () {
        return this.htmlStr;
    };
    LoopInlineNodes.prototype._loop = function (ele) {
        if (ele.nodeType === 3) {
            var len = ele.length;
            for (var i = 0; i < len; i++) {
                this.htmlStr += '<span class="emr">' + ele[i] + '</span>';
            }
        }
        else {
            var startTag = '';
            var endTag = '';
            if (this.regexp.test($(ele)[0].outerHTML)) {
                startTag = RegExp.$1;
                endTag = RegExp.$2;
            }
            this.htmlStr += startTag;
            var contentsArr = $(ele).contents();
            if (contentsArr && contentsArr.length > 0) {
                $.each(contentsArr, function (i, n) {
                    this._loop(n);
                });
            }
            this.htmlStr += endTag;
        }
    };
    return LoopInlineNodes;
}());
function $(ele) {
    return {
        contents: function () { },
        each: function (a, b) { }
    };
}
